<?php
require_once("vcl/vcl.inc.php");
require_once("lib/db_connection.php");
//Includes
use_unit("components4phpfull/jtjavascript.inc.php");
use_unit("platinumgrid/jtplatinumgrid.inc.php");
use_unit("components4phpfull/jtsitetheme.inc.php");
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");

//Class definition
class Queue_List extends Page
{
       public $JSPrint = null;
       public $JTJavaScript2 = null;
       public $imgAdd = null;
       public $JTJavaScript1 = null;
       public $JSView = null;
       public $Image1 = null;
       public $JTGridQueue = null;
       public $JTSiteTheme1 = null;

       function Queue_ListCreate($sender, $params)
       {
       $this->imgAdd->setLink('queue_slip.php');


       }

       function imgAddJSMouseOut($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imgAdd'].src="image/add_new.png"
       <?php

       }

       function imgAddJSMouseOver($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imgAdd'].src="image/add_new_blue.png"
       <?php

       }

       function JTGridQueueShow($sender, $params)
       {
       //$query_list = "SELECT * FROM queue_tbl WHERE company_id='".$_SESSION['company_id']."' order by queue_no ASC";
       $query_list = "SELECT * FROM queue_tbl WHERE company_id='".$_SESSION['company_id']."' order by timestamp DESC";
       $result_list = mysql_query($query_list) or die("SELECT QUEUES ".mysql_error());
       $grid_arr = array();
       while($row_list = mysql_fetch_array($result_list))
       {


        $queue_no = $row_list['queue_no'];
        $plate_no = $row_list['plate_no'];
        $driver_name = $row_list['driver_name'];
        $hauler_name = $row_list['hauler_name'];
        $customer_name = $row_list['cust_name'];

        $query_veh = "SELECT * FROM dts_veh_tbl WHERE vehicle_id='".$row_list['plate_id']."'";
        $result_veh = mysql_query($query_veh) or die("SELECT VEH ".mysql_error());
        $row_veh = mysql_fetch_array($result_veh);

        $queue_num = "<a href=queue_edit.php?autoid=".base64_encode($row_list['autoid'])." title='edit queue'>".$queue_no."</a>";

        $tools = "<img src='image/view.png' onClick=jsview('".base64_encode($row_list['autoid'])."') title='View Queue Slip' style='height:25px;width:25px;cursor:pointer;'/>
        <img src='image/change_stat.png' onClick=jschange('".base64_encode($row_list['autoid'])."') title='Change Status' style='height:25px;width:25px;cursor:pointer;'/>
        <img src='image/print.png' onClick=jsPrint('".base64_encode($row_list['autoid'])."') title='Print' style='height:25px;width:25px;cursor:pointer;'/>
        <img src='image/delete.png' onClick=jsdelete('".base64_encode($row_list['autoid'])."') title='Delete' style='height:25px;width:25px;cursor:pointer;'/>";

        $grid_arr[] = array(
        "Queue #" => $queue_num,
        "Plate" => $plate_no,
        "Truck Type" => $row_veh['style_name'],
        "Driver" => $driver_name,
        "Hauler" => $hauler_name,
        "Customer" => $customer_name,
        "Status"=>$row_list['status'],
        "Tools" => $tools
        );
       }
       $this->JTGridQueue->setCellData($grid_arr);
       }


}

global $application;

global $Queue_List;

//Creates the form
$Queue_List=new Queue_List($application);

//Read from resource file
$Queue_List->loadResource(__FILE__);

//Shows the form
$Queue_List->show();

?>